/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ArquivoServidor;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.util.LinkedList;

/**
 *
 * @author saracristhina
 */
public class Servidor {
   ServerSocket servidor;
   LinkedList lista;
   Socket conexao;
   ObjectOutputStream saida;
   ObjectInputStream entrada;
   //public static Socket conexao;
    public Servidor() {
    // servidor= new ServerSocket(6789, 2);     
    }
    
public void ConectarServidor() throws IOException, ClassNotFoundException{
         
        //ServerSocket servidor = new ServerSocket(6789, 2);
        servidor= new ServerSocket(6789, 2);
        System.out.println("iniciou o servidor");
        conexao = servidor.accept();

              
            saida = new ObjectOutputStream(conexao.getOutputStream());
            SocketAddress end = conexao.getRemoteSocketAddress();
            System.out.println("Enviando um n�mero ao cliente" + end.toString());
            entrada=new ObjectInputStream(conexao.getInputStream() ); 
            //BufferedReader inFromClient = new BufferedReader(new InputStreamReader(conexao.getInputStream()));  
            lista=(LinkedList) entrada.readObject();
            System.out.println("chegou isso" +lista);
            //dando erro aqui.
            int teste=0;
            teste=Arquivo.pointsCalc(lista);
            System.out.println("teste "+teste);
            int i=0;
            i=teste;
            //saida.writeObject(lista);
            saida.write(teste);
            saida.writeInt(47);
             
            saida.flush();
        
}

public void receberDados(){
    
}

public void encerrarConexao(){
    
}
}
